package by.wind.drebedengi.datalayer.bean;

import java.util.Date;

import com.j256.ormlite.field.DatabaseField;

public class Record {
	
	@DatabaseField(generatedId = true)
	private long client_id;
	@DatabaseField
	private long server_id;
	@DatabaseField(canBeNull = false, foreign = true, foreignAutoRefresh = true, columnName = "currency_id")
	private Currency currency;
	@DatabaseField
	private Date operation_date;
	@DatabaseField
	private String comment;
	@DatabaseField
	private long sum;
	@DatabaseField
	private boolean is_duty;
	@DatabaseField
	private int operation_type;
	@DatabaseField(canBeNull = true, foreign = true, foreignAutoRefresh = true, columnName="place_id")
	private Place place;
	@DatabaseField(canBeNull = true, foreign = true, foreignAutoRefresh = true, columnName="category_id")
	private Category category;
	@DatabaseField(canBeNull = true, foreign = true, foreignAutoRefresh = true, columnName="source_id")
	private Source source;
	
	public final static long QUALIFICATION = 100;


	public static final String ID = "id";
	public static final String CLIENT_ID = "client_id";
	public static final String SERVER_ID = "server_id";
	public static final String CURRENCY_ID = "currency_id";
	public static final String OPERATION_DATE = "operation_date";
	public static final String COMMENT = "comment";
	public static final String SUM = "sum";
	public static final String IS_DUTY = "is_duty";
	public static final String OPERATION_TYPE = "operation_type";
	public static final String PLACE_ID = "place_id";
	public static final String BUDGET_OBJECT_ID = "budget_object_id";
	
	public long getClient_id() {
		return client_id;
	}
	public void setClient_id(long client_id) {
		this.client_id = client_id;
	}
	public long getServer_id() {
		return server_id;
	}
	public void setServer_id(long server_id) {
		this.server_id = server_id;
	}
	public Date getOperation_date() {
		return operation_date;
	}
	public void setOperation_date(Date operation_date) {
		this.operation_date = operation_date;
	}
	public String getComment() {
		return comment;
	}
	public void setComment(String comment) {
		this.comment = comment;
	}
	public long getSum() {
		return sum;
	}
	public void setSum(long sum) {
		this.sum = sum;
	}
	public boolean isIs_duty() {
		return is_duty;
	}
	public void setIs_duty(boolean is_duty) {
		this.is_duty = is_duty;
	}
	public int getOperation_type() {
		return operation_type;
	}
	public void setOperation_type(int operation_type) {
		this.operation_type = operation_type;
	}
	public Place getPlace() {
		return place;
	}
	public void setPlace(Place place) {
		this.place = place;
	}
	public Currency getCurrency() {
		return currency;
	}
	public void setCurrency(Currency currency) {
		this.currency = currency;
	}

	public Category getCategory() {
		return category;
	}
	public void setCategory(Category category) {
		this.category = category;
	}

	public Source getSource() {
		return source;
	}
	public void setSource(Source source) {
		this.source = source;
	}
	
	public String toString() {
		return "Currency: \n" +
				CLIENT_ID + " = " + client_id + "\n" +
				SERVER_ID + " = " + server_id + "\n" +
				CURRENCY_ID + " = " + (currency!=null?currency.getServer_id():null) + "\n" +
				OPERATION_DATE + " = " + operation_date + "\n" +
				COMMENT + " = " + comment + "\n" +
				SUM + " = " + sum + "\n" +
				IS_DUTY + " = " + is_duty + "\n" +
				OPERATION_TYPE + " = " + operation_type + "\n" +
				PLACE_ID + " = " + (place!=null ? place.getServer_id() : null) + "\n" +
				"category_id" + " = " + (category!=null ? category.getServer_id() : null) + "\n" + 
				"source_id" + " = " + (source!=null ? source.getServer_id() : null) + "\n";
	}

}
